#!/bin/bash

if [[ $# < 1 ]]; then
    echo "参数不够"
    exit
fi

case $1 in
"start")
    echo "==========================hadoop集群启动==========================="
    echo "-------------------启动hdfs----------------------"
    ssh fengliulin@hadoop102 "/opt/hadoop-3.3.6/sbin/start-dfs.sh"
    echo "-------------------启动yarn----------------------"
    ssh fengliulin@hadoop103 "/opt/hadoop-3.3.6/sbin/start-yarn.sh"
    echo "-------------------启动historyserver----------------------"
    ssh fengliulin@hadoop102 "/opt/hadoop-3.3.6/bin/mapred --daemon start historyserver"
    ;;
"stop")
    echo "==========================hadoop集群关闭==========================="
    echo "-------------------关闭historyserver----------------------"
    ssh fengliulin@hadoop102 "/opt/hadoop-3.3.6/bin/mapred --daemon stop historyserver"
    echo "-------------------关闭yarn----------------------"
    ssh fengliulin@hadoop103 "/opt/hadoop-3.3.6/sbin/stop-yarn.sh"
    echo "-------------------关闭hdfs----------------------"
    ssh fengliulin@hadoop102 "/opt/hadoop-3.3.6/sbin/stop-dfs.sh"
    ;;
*)
    echo "参数输入错误, 请输入 start 或者 stop"
    ;;

esac
